import axios from '../config.js'

// 购物车列表
export function getCartList() {
    const url = '/mobile/cart/getList'
    return axios.get(url)
}

// 加入购物车
export function addCart(cartGoodsId, goodsQuantity) {
    const url = '/mobile/cart/addCart'
    const data = {
        cartGoodsId: cartGoodsId,
        goodsQuantity: goodsQuantity
    }
    return axios.post(url, data)
}

// 删除购物车商品
export function deleteCartInfo(cartGoodsIds) {
    const url = '/mobile/cart/deleteInfo'
    const data = {
        cartGoodsIds: cartGoodsIds
    }
    return axios.post(url, data)
}

// 获取购物车商品数量
export function getCartCount() {
    const url = '/mobile/cart/getCartCount'
    return axios.get(url)
}

// 修改购物车数量
export function changeCartGoodsQuantity(cartGoodsId, goodsQuantity) {
    const url = '/mobile/cart/changeCart'
    const data = {
        cartGoodsId: cartGoodsId,
        goodsQuantity: goodsQuantity
    }
    return axios.post(url, data)
}

// 确认订单
export function settleCart(cartGoodsIds) {
    const url = '/mobile/cart/settle'
    const data = {
        cartGoodsIds: cartGoodsIds
    }
    return axios.post(url, data)
}

// 确认订单数据
export function cartOrderInfo(cartGoodsIds, addressId) {
    const url = '/mobile/Order/makeOrder'
    const data = {
        cartGoodsIds: cartGoodsIds,
        addressId: addressId
    }
    return axios.post(url, data)
}